
<?php      
    
     $dtpApplyDate=(isset($ApplyDate) && !empty($ApplyDate) && is_date($ApplyDate)) ? $ApplyDate : date('Y-m-d');
     $dtpApplyDate=str_replace('/','-',$dtpApplyDate); 
     $arrApplyDate= explode('-', $dtpApplyDate) ;   

?>
<script>
	 $(function() {
             
            var defaultYear= <?php echo $arrApplyDate[0] ?>;
            var defaultMonth= <?php echo $arrApplyDate[1]-1 ?>;                        
            $( "#datepicker" ).datepicker({
              showOn: "button",
              buttonImage: "/public/sites/images/calendaricon.gif",
              //dateFormat: 'yy/mm/dd',
              dateFormat: 'yy/mm',
              yearRange: '<?php echo $this->session->userdata('minYear') . ':' . $this->session->userdata('maxYear'); ?>',
              buttonImageOnly: true,
              changeMonth: true,
              changeYear: true,
              showButtonPanel:true,
              //defaultDate: '<?php echo $dtpApplyDate; ?>',
              
              
              beforeShowDay: function(date) {
                    return [date.getDate() == 1]
                },
              onClose: function(dateText, inst) { 
                var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                $(this).datepicker('setDate', new Date(year, month, 1));
                }  ,
                        defaultDate: new Date(defaultYear,defaultMonth,1)
            });
            
          });
          //
   
</script>
<style>
    .ui-datepicker-calendar {
    display: none;
    }​    
    button.ui-datepicker-current{ display: none !important;}
/*   .ui-datepicker table{
       display: none;
   }*/
</style>
<div id="main_content">
	<h3><?php echo $title; ?></h3>
    <div class="form_add">
	<?php
       echo "<label for='disabledSelect' style='color:red;'>".$this->session->flashdata('message')."</label>";
    ?>    
    <form action="" method="post">
       <table border="0" class="add_data">  
           <tr>
               <td><a href="<?php echo base_url(); ?>pit-parameter" class="btn addEmoloyeeBack m10"><?php echo $this->lang->line('MC013'); ?></a></td>  
                </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('pcpr__Employeedeductionamount'); ?> <span class="requied"> (*)</span></label>
                </td>
                <td>                	
                        <?php 
                            $optionEmployeeDeductionAmount = array(
                                    'name'        => 'txtEmployeeDeductionAmount',                                   
                                    'value'       => isset($EmployeeDeductionAmount) ? $EmployeeDeductionAmount : '',
                                    'maxlength'   => '8'                                   
                                  );
                            echo form_input($optionEmployeeDeductionAmount)  ; ?>
                            
                        
                </td>
                <td>
                    <span class="error"><?php echo form_error('txtEmployeeDeductionAmount'); ?>
                </td>
                
            </tr>
       		<tr>
            	<td align="right">                	

                	<label><?php echo $this->lang->line('pcpr__Deductionpersondependant'); ?><span class="requied"> (*)</span></label>
                </td>
                <td>                	
                        <?php 
                            $optionDeductionPerDependant = array(
                                    'name'        => 'txtDeductionPerDependant',                                   
                                    'value'       => isset($DeductionPerDependant) ? $DeductionPerDependant : '',
                                    'maxlength'   => '8'                                   
                                  );
                            echo form_input($optionDeductionPerDependant)  ;
                            ?>
                        
                </td>
                <td><span class="error"><?php echo form_error('txtDeductionPerDependant'); ?></td>
            </tr>
       		<tr>
            	<td align="right">
                	<label><?php echo $this->lang->line('pcpr__Applydate'); ?><span class="requied"> (*)</span></label>
                </td>
                <td>
                	<?php                     
                            function is_date( $str ){                               
                                if(strlen($str)==7 || strlen($str)==10){
                                    $stamp = strtotime( $str ); 
                                    if (!is_numeric($stamp)) 
                                        return FALSE; 
                                    $month = date( 'm', $stamp );
                                    //$day   = date( 'd', $stamp ); 
                                    $year  = date( 'Y', $stamp ); 
                                    $day=1;                                    
                                    if (checkdate($month, $day, $year)) 
                                        return TRUE; 
                                }else{
                                    return FALSE; 
                                }
                            }
                            if(isset($ApplyDate) && !empty($ApplyDate) && is_date($ApplyDate)){                                
                                 $ApplyDate=date("Y/m", strtotime($ApplyDate));
                            }elseif(isset($ApplyDate) && !empty($ApplyDate)){                          
                                $ApplyDate=$ApplyDate;
                            }else{
                                $ApplyDate="";
                            }                    
                            $options = array(
                                    'name'        => 'txtApplyDate',
                                    'id'          => 'datepicker',
                                    'value'       => $ApplyDate,
                                     'maxlength'   =>7,
                                    'size'        => '20',                                   
                                  );
                        ?>
                             <?php echo form_input($options)  ; ?>                	
                            
                        
                    <?php echo $this->lang->line('emp_bu_formatDate');?>
                </td>
                <td><span class="error"><?php echo form_error('txtApplyDate'); ?><?php echo isset($errDuplicateDate) ?  $errDuplicateDate: ''; ?></span></td>
            </tr>
            <?php if(isset($Del_Flag)){ ?>
            <tr>
                <td align="right"><?php echo $this->lang->line('spl__Delete');?></td>
                <td><input type="checkbox" <?php echo ($Del_Flag==1) ? 'checked' : ''?> name="chkDelete" /></td>
            </tr>
            <?php } ?>
       		<tr>         
                <td colspan="2" align="left">
                    <input type="hidden" id="hidParameterID" name="hidParameterID" value="<?php echo isset($ParameterId) ? $ParameterId : ''; ?>">
                    <input type="hidden" value="true" name="btnButton"/>
                    <input id="btnSubmit" name="btnSubmit" type="submit" value="<?php echo $this->lang->line('MC008'); ?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input style="display:none;" type="reset" name="reset" value="<?php echo $this->lang->line('MC009'); ?>">
                </td>
            </tr>                                                                                         
       </table> 
    </form>
        
    </div>
</div>
<div  id="dialog" title="<?php echo $dialogTitle; ?>">
    <?php echo isset($message) ? $message : ''; ?>
</div>
<script type="text/javascript">
     
<?php if (isset($flag) && $flag == TRUE): ?>
            $(function() {
                $("#dialog").dialog({
                    closeText: "hide",
                    modal: true,
                    close: function() {
                        window.location.href = '<?php echo base_url('/pit-parameter'); ?>';
                    },
                    buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                window.location.href = '<?php echo base_url('/pit-parameter'); ?>';
                            }
                        }],
                });
            });
<?php elseif (isset($flag) && $flag == FALSE): ?>
            $(function() {
                $("#dialog").dialog({
                    resizable: false,
                    height:140,
                    modal: true,
                    buttons: [{
                            text: '<?php echo $this->lang->line('MC019'); ?>',
                            click: function() {
                                $("#dialog").dialog('close');
                            }
                        }]
                  });
            });
<?php endif; ?>
   
</script>